﻿using System;
using System.Globalization;

namespace OWE.Service.Configuration
{
    public class ConvertHelper
    {
        public static T ConvertValue<T>(object configValue)
        {
            try
            {
                if (configValue is IConvertible)
                    return (T)Convert.ChangeType(configValue, typeof(T), new CultureInfo("en-US"));
                return (T)Convert.ChangeType(configValue, typeof(T));
            }

            catch (Exception exp)
            {
                throw new Exception("Conversion process fail : " + exp.Message);
            }
        }
    }
}
